<template>
  <div class="msgBox">
    <el-card class="box-card" shadow="hover">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-image style="width: 100px; height: 100px" src="" fit="cover" />
        </el-col>
        <el-col :span="18">
          <el-form ref="form" :model="userInfo" size="mini" label-width="80px">
            <el-form-item label="姓名">
              <div>{{ userInfo.name }}</div>
            </el-form-item>
            <el-form-item label="手机号">
              <div>{{ userInfo.phoneNumber }}</div>
            </el-form-item>
            <el-form-item label="email">
              <div>{{ userInfo.email }}</div>
            </el-form-item>
            <el-form-item label="id">
              <div>{{ userInfo.id }}</div>
            </el-form-item>
            <el-form-item label="租户id">
              <div>{{ userInfo.tenantId }}</div>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { getUserToken, getLocalToken } from '@/lib/auth'; // get token from cookie
export default {
  data() {
    return {
      userInfo: {}
    };
  },
  mounted() {
    this.getuserMsg();
  },
  methods: {
    getuserMsg: async function() {
      const hasToken = getLocalToken() || (await getUserToken());
      console.log(hasToken);
      if (hasToken) {
        // 获取用户信息
        this.$store.dispatch('user/getInfo').then(userInfo => {
          console.log(userInfo);
          this.userInfo = userInfo;
        });
      }
    }
  }
};
</script>

<style lang="scss">
.msgBox {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  min-height: calc(100vh - 40px);
  .box-card {
    width: 800px;
  }
}
</style>
